    <div class="row">
		  <div class="col-xs-6 col-md-3">
		  <form action="">
		    <div class="input-group">
		      <input type="text" name="search" class="form-control" placeholder="用户名、邮箱..." value="<?php echo $search;?>">
		      <span class="input-group-btn">
		        <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
		      </span>
		      
		    </div>
		    </form>
		  </div>
		  <div class="col-xs-6 col-md-9">
		  		<button type="button" onclick="user_add();" class="btn btn-success pull-right">新增</button>
		  </div>
		</div>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>#</th>
                  <th>用户名</th>
                  <th>邮箱</th>
                  <th>角色</th>
                  <th>创建时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              	<?php foreach ($users as $item):?>
              		<tr id="user_<?=$item['id']?>">
              			  <td><?=$item['id']?></td>
              			  <td><?=$item['name']?></td>
		                  <td><?=$item['username']?></td>
		                  <td>网站管理员</td>
		                  <td><?=$item['created_at']?></td>
		                  <td>
		                  		<div class="btn-group" role="group" aria-label="...">
		                  			<button type="button" onclick="user_edit(<?=$item['id']?>);" class="btn btn-primary btn-sm">编辑</button>
                            <button type="button" onclick="user_repassword(<?=$item['id']?>);" class="btn btn-warning btn-sm">重置密码</button>
								  	       <button type="button" onclick="user_delete(<?=$item['id']?>);" class="btn btn-danger btn-sm">删除</button>
							  	        </div>
						          </td>
		              </tr>
          		<?php endforeach;?>
              </tbody>
            </table>
<?php echo $pagenation;?>
</div>
 <script type="text/javascript">
function user_delete(id){
  var name = $('#user_'+id).children('td').eq(1).text();
  $.alert('提示','确定删除用户<b class="text-danger">'+name+'</b>?',function(modal){
    modal.modal('hide');
    var loading = layer.load(1,{shade: [0.5,'#000']});
    $.post('<?php echo site_url('admin/administrator/delete');?>',{id:id},function(result){
      if(result.statu=='ok'){
          location.reload();
      }else{
        layer.close(loading);
        layer.msg(result.message,{icon: 2});
      }
    })
  },function(modal){
    modal.modal('hide');
  })
}

function user_form(data){
  if(!data) data = {name:'',username:''};
  var html = '<form id="user_form">';
  if(data.id) html+='<input type="hidden" name="id" value="'+data.id+'" />';
  html+=makeInput({name:'username',label:'邮箱',value:data.username});
  html+=makeInput({name:'name',label:'用户名',value:data.name});
  html+='</form>';
  return html;
}

function user_edit(id){
  var $td = $('#user_'+id).children('td');
  var data = {id:id};
  data.name = $td.eq(1).text();
  data.username = $td.eq(2).text();
  var html = user_form(data);
  $.alert('修改用户',html,function(modal){
    var formData = $("#user_form").serializeJson();
    formData.name = $.trim(formData.name);
    if(formData.username.length<6||formData.username.length>30){
      $('#alert_form_username').formTip('邮箱长度为6-30！','error',false);
      return;
    }
    if(formData.name.length<1||formData.name.length>20){
      $('#alert_form_name').formTip('用户名长度为1-20！','error',false);
      return;
    }
    modal.modal('hide');
    var loading = layer.load(1, {shade: [0.5,'#000']});
    $.post('<?php echo site_url('admin/administrator/form');?>',formData,function(result){
      layer.close(loading);
      $.alert('提示',result.message,function(modal){
        modal.modal('hide');
        if(result.statu=='ok') location.reload();
      });
    })
  },function(modal){
    modal.modal('hide');
  });  
}

function user_repassword(id){
  var name = $('#user_'+id).children('td').eq(1).text();
  $.alert('提示','确定重置用户<b class="text-danger">'+name+'</b>的密码?',function(modal){
    modal.modal('hide');
    var loading = layer.load(1,{shade: [0.5,'#000']});
    $.post('<?php echo site_url('admin/administrator/resetpassword');?>',{id:id},function(result){
      modal.modal('hide');
      layer.close(loading);
      $.alert('提示',result.message,function(modal){
        modal.modal('hide');
      })
    })
  },function(modal){
    modal.modal('hide');
  })
}
function user_add(){
  var html = user_form();
  $.alert('增加用户',html,function(modal){
    var formData = $("#user_form").serializeJson();
    formData.name = $.trim(formData.name);
    if(formData.username.length<6||formData.username.length>30){
      $('#alert_form_username').formTip('邮箱长度为6-30！','error',false);
      return;
    }
    if(formData.name.length<1||formData.name.length>20){
      $('#alert_form_name').formTip('用户名长度为1-20！','error',false);
      return;
    }
    modal.modal('hide');
    var loading = layer.load(1, {shade: [0.5,'#000']});
    $.post('<?php echo site_url('admin/administrator/form');?>',formData,function(result){
      layer.close(loading);
      $.alert('提示',result.message,function(modal){
        modal.modal('hide');
        if(result.statu=='ok') location.reload();
      });
    })
  },function(modal){
    modal.modal('hide');
  });
}


</script>
        